package kr.hkit.PowerJava.chapter17;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.SwingConstants;

public class SwingComponentAll extends JFrame {

	private JPanel contentPane;
	private JPanel panelImage;
	private JPanel panelchekbox;
	private JPanel panelRadio;
	private JLabel lblNewLabel;
	private JButton btnNewButton;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SwingComponentAll frame = new SwingComponentAll();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SwingComponentAll() {
		initialize();
	}
	private void initialize() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
		
		panelImage = new JPanel();
		contentPane.add(panelImage);
		panelImage.setLayout(new BorderLayout(0, 0));
		
		lblNewLabel = new JLabel("이미지를 보려면 아래버튼을 누르세요");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		panelImage.add(lblNewLabel, BorderLayout.CENTER);
		
		btnNewButton = new JButton("이미지레이블");
		btnNewButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				
				ImageIcon icon = new ImageIcon("aa.jpg");
				lblNewLabel.setIcon(icon);
				lblNewLabel.setText(null);
				
			}
		} );
		panelImage.add(btnNewButton, BorderLayout.SOUTH);
		
		panelchekbox = new JPanel();
		contentPane.add(panelchekbox);
		
		panelRadio = new JPanel();
		contentPane.add(panelRadio);
	}

}
